/* GUI CONVERTED from rcrp11.p (converter v1.76) Wed May 29 02:08:23 2002 */
/* rcrp11.p - Release Management Customer Schedules                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.23.1.21 $                                                     */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.3      LAST MODIFIED: 10/16/92   BY: WUG *G462*                */
/* REVISION: 7.3      LAST MODIFIED: 05/07/93   BY: WUG *GA76*                */
/* REVISION: 7.3      LAST MODIFIED: 09/20/93   BY: WUG *GF68*                */
/* REVISION: 7.3      LAST MODIFIED: 09/30/93   BY: WUG *GG12*                */
/* REVISION: 7.4      LAST MODIFIED: 10/04/93   BY: WUG *H153*                */
/* REVISION: 7.4      LAST MODIFIED: 10/25/93   BY: WUG *H193*                */
/* REVISION: 7.3      LAST MODIFIED: 04/15/94   BY: WUG *GJ40*                */
/* REVISION: 7.4      LAST MODIFIED: 08/03/94   BY: dpm *GL08*                */
/* REVISION: 7.4      LAST MODIFIED: 11/01/94   BY: ame *GN84*                */
/* REVISION: 7.4      LAST MODIFIED: 11/19/94   BY: GWM *H604*                */
/* REVISION: 7.4      LAST MODIFIED: 12/15/94   BY: rxm *GN16*                */
/* REVISION: 7.4      LAST MODIFIED: 01/20/95   BY: srk *G0C1*                */
/* REVISION: 7.4      LAST MODIFIED: 04/06/95   BY: ame *H0CF*                */
/* REVISION: 7.4      LAST MODIFIED: 04/21/95   BY: bcm *G0KN*                */
/* REVISION: 7.4      LAST MODIFIED: 09/07/95   BY: vrn *G0WM*                */
/* REVISION: 7.4      LAST MODIFIED: 09/15/95   BY: vrn *G0VP*                */
/* REVISION: 7.4      LAST MODIFIED: 10/15/95   BY: vrn *G0ZR*                */
/* REVISION: 7.4      LAST MODIFIED: 01/26/96   BY: ais *G1L7*                */
/* REVISION: 7.3      LAST MODIFIED: 06/18/96   BY: tzp *G1YB*                */
/* REVISION: 7.4      LAST MODIFIED: 10/04/96   BY: *G2GG* Sanjay Patil       */
/* REVISION: 8.6      LAST MODIFIED: 03/15/97   BY: *K04X* Steve Goeke        */
/* REVISION: 8.6      LAST MODIFIED: 04/02/97   BY: *K09H* Vinay Nayak-Sujir  */
/* REVISION: 8.6      LAST MODIFIED: 04/09/97   BY: *G2LS* Jim Williams       */
/* REVISION: 8.6      LAST MODIFIED: 06/20/97   BY: *H19N* Aruna Patil        */
/* REVISION: 8.6      LAST MODIFIED: 10/30/97   BY: *K139* Joe Gawel          */
/* REVISION: 8.6      LAST MODIFIED: 11/07/97   BY: *K18J* Jean Miller        */
/* REVISION: 8.6      LAST MODIFIED: 11/25/97   BY: *J26R* Niranjan R.        */
/* REVISION: 8.6      LAST MODIFIED: 12/13/97   BY: *J20Q* Aruna Patil        */
/* REVISION: 8.6      LAST MODIFIED: 12/19/97   BY: *J28J* Manish K.          */
/* REVISION: 8.6e     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6e     LAST MODIFIED: 04/27/98   BY: *K1NR* A. Licha           */
/* REVISION: 8.6e     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6e     LAST MODIFIED: 06/08/98   BY: *K1RZ* Ashok Swaminathan  */
/* REVISION: 8.6e     LAST MODIFIED: 07/20/98   BY: *H1MC* Mansih K.          */
/* REVISION: 8.6e     LAST MODIFIED: 08/22/98   BY: *K1W8* Poonam Bahl        */
/* REVISION: 9.1      LAST MODIFIED: 07/15/99   BY: *N012* Mugdha Tambe       */
/* REVISION: 9.1      LAST MODIFIED: 09/23/99   BY: *K230* Santosh Rao        */
/* REVISION: 9.1      LAST MODIFIED: 11/19/99   BY: *N004* Steve Nugent       */
/* REVISION: 9.1      LAST MODIFIED: 12/29/99   BY: *M0F3* Santosh Rao        */
/* REVISION: 9.1      LAST MODIFIED: 12/28/99   BY: *N05X* Surekha Joshi      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 04/10/00   BY: *L0RG* Santosh Rao        */
/* REVISION: 9.1      LAST MODIFIED: 06/20/00   BY: *J3PY* Santosh Rao        */
/* REVISION: 9.1      LAST MODIFIED: 07/05/00   BY: *N0F4* BalbeerS Rajput    */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* REVISION: 9.1      LAST MODIFIED: 08/18/00   BY: *N0MC* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 12/02/00   BY: *M0X8* Santosh Rao        */
/* REVISION: 9.1      LAST MODIFIED: 12/22/00   BY: *M0YP* Rajaneesh S.       */
/* REVISION: 9.1      LAST MODIFIED: 10/04/00   BY: *N0WD* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.23.1.17     BY: Ellen Borden       DATE: 07/09/01  ECO: *P007* */
/* Revision: 1.23.1.18     BY: Ashwini G.         DATE: 11/09/01  ECO: *N160* */
/* Revision: 1.23.1.19     BY: Jean Miller        DATE: 12/13/01  ECO: *P03Q* */
/* Revision: 1.23.1.20     BY: Katie Hilbert      DATE: 04/15/02  ECO: *P03J* */
/* $Revision: 1.23.1.21 $    BY: Mamata Samant      DATE: 05/28/02  ECO: *N1K3* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* THE CALL TO THE PROGRAMS sopma.p and rcrp11b.p HAS BEEN REMOVED AS   */
/* THEY HAVE BEEN OBSOLETED BY THE PATCH N1K3                           */

/* SHIPPER PRINT */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}
{cxcustom.i "RCRP11.P"}

define new shared variable addr as character format "x(38)" extent 6.

define shared variable global_recid as recid.

define variable billto  as character format "x(38)" extent 6 no-undo.
define variable shipto  as character format "x(38)" extent 6 no-undo.
define variable company as character format "x(38)" extent 6 no-undo.

define variable type like mfc_logical label "Type" format "Shipper/Container"
   initial yes no-undo.
define variable ctype       as character label "T" format "x(1)" no-undo.
define variable disp_abs_id as character no-undo.
define variable print_date  as date no-undo.
define variable pages       as integer no-undo.
define variable cust        like so_cust no-undo.
define variable ship        like so_ship no-undo.
define variable addr_id     as character no-undo.
define variable abs_shipvia like so_shipvia no-undo.
define variable abs_fob     like so_fob no-undo.

define variable abs_trans_mode as character format "x(20)"
   label "Mode of Transport" no-undo.
define variable abs_carr_ref   as character format "x(20)"
   label "Carrier Shipment Ref" no-undo.
define variable abs_veh_ref    as character format "x(20)"
   label "Vehicle ID" no-undo.

define variable rpt_type     as character format "x(23)" no-undo.
define variable type_nbr     as character format "x(17)" no-undo.
define variable par_shipfrom as character no-undo.
define variable par_id       as character no-undo.

define variable disp_item as character format "x(26)" label "Item Number" no-undo.
define variable cum_qty like sod_cum_qty[1] extent 0 no-undo.
define variable abs_twt like abs_gwt label "Tare Weight" no-undo.
define variable abs_recid as recid no-undo.
define variable soldto_id as character no-undo.
define variable shipto_id as character no-undo.
define variable i as integer no-undo.

define variable shipper_id    like abs_id no-undo.
define variable ship_date     as   date no-undo.
define variable abs-confirm   as   character format "x(1)" no-undo.
define variable order-um      like um_um no-undo.
define variable shipfrom      like abs_shipfrom no-undo.
define variable shp-id        like abs_id no-undo.
define variable ship_qty      like abs_qty no-undo.
define variable absshipto     like abs_shipto no-undo.
define variable lot-lbl       as   character format "x(56)" no-undo.
define variable comp_addr     like ad_addr label "Company Address" no-undo.
define variable ld-expire     like ld_expire no-undo.
define variable l_print_sodet like mfc_logical initial no
   label "Print Sales Order Detail" no-undo.
define variable msgdesc       like msg_desc initial "" format "x(62)" no-undo.

define variable sequence_list    as character format "x(36)" no-undo.
define variable v_start_page     as integer no-undo.
define variable abs_recid_seq    as recid no-undo.
define variable l_abs_shipto     like abs_shipto no-undo.

define variable l_abs_twt        like abs_gwt   no-undo.
define variable l_first_part_um  like abs_wt_um no-undo.
define variable l_conv           as   decimal   no-undo.
define variable l_net_wt1        like abs_nwt   no-undo.
define variable l_gross_wt1      like abs_gwt   no-undo.
define variable l_tare_wt1       like abs_gwt   no-undo.
define variable l_net_wt2        like abs_nwt   no-undo.
define variable l_gross_wt2      like abs_gwt   no-undo.
define variable l_tare_wt2       like abs_gwt   no-undo.
define variable l_qty            like abs_qty   no-undo.
define variable l_part_um        like abs_wt_um no-undo.
define variable v_absd_fld_seq   like absd_fld_seq no-undo.
define variable v_absd_fld_name  like absd_fld_name no-undo.
define variable v_absd_fld_value like absd_fld_value no-undo.

define variable shipper-po          like sod_contr_id format "x(22)" no-undo.
define variable l_parent_tare_wt    like abs_nwt        no-undo.
define variable using_seq_schedules like mfc_logical initial no no-undo.
define variable non_blank_so_stat   like mfc_logical initial no no-undo.
define variable print_lotserials    like  mfc_logical initial no
   label "Print Lot/Serial Numbers" no-undo.

define workfile abs_work
   field abs-lotser like abs_lotser
   field abs-ref like abs_ref
   field abs-qty like abs_qty
   field abs-loc like abs_loc
   field abs-site like abs_site.

/* ADDED THE FOLLOWING TABLE TO PRINT CUSTOMER SEQUENCES */
define new shared temp-table t_abss_det no-undo
   field t_abss_ship_id like abss_ship_id
   field t_abss_from_cust_job like abss_cust_job
   field t_abss_from_cust_seq like abss_cust_seq
   field t_abss_to_cust_job like abss_cust_job
   field t_abss_to_cust_seq like abss_cust_seq.

/* VARIABLE DEFINITIONS FOR gpfile.i */
{gpfilev.i}

/* DEFINING FORMS FOR CUSTOMER SEQUENCES */
FORM /*GUI*/ 
   t_abss_from_cust_seq    at 10
   t_abss_to_cust_seq      label "To"
with STREAM-IO /*GUI*/  down frame sequence2 width 80.

/* SET EXTERNAL LABELS */
setFrameLabels(frame sequence2:handle).


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
type              colon 28
   shipfrom          colon 28 label "Ship-From"
   si_desc           at 45    no-label
   shp-id            colon 28 label "Shipper/Container ID"
   print_lotserials  colon 28
   l_print_sodet     colon 28
   comp_addr         colon 28
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   abs_loc     colon 20  label "Ship-From Location"
   ad_name     at 45     no-label
   abs_shipto  colon 20  label "Ship-To/Dock"
   ad_line1    at 45     no-label
with STREAM-IO /*GUI*/  frame b side-labels width 80 attr-space.

/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

/*   Because work_abs_mstr has not been defined before the form
     defn, "abs_qty" field in the form is interpreted as
     abs_mstr.abs_qty instead of work_abs_mstr.abs_qty which
     is how we want to use the field.
     Using "abs_qty" here causes an dummy field to appear on the
     form in addition to work_abs_mstr.abs_qty field. So changed
     it to a local var "ship_qty" */

FORM /*GUI*/ 
   disp_item   column-label "Item Number!Rev"
   shipper-po
   ship_qty    column-label "Qty Shipped"
               format "->>>>>>9.99<<<<<<"
   cum_qty     column-label "Cumulative!Qty Shipped"
               format "->>>>>>>>>9.99<<<<<<"
   pt_um
with STREAM-IO /*GUI*/  frame c width 80 down no-box.

/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).

/* DEFINING FORM FOR CONTAINER/LINE CHARGES */
FORM /*GUI*/ 
   space(5)
   v_absd_fld_seq
   v_absd_fld_name
   v_absd_fld_value
with STREAM-IO /*GUI*/  down frame absd_user_fields width 80.

/* SET EXTERNAL LABELS */
setFrameLabels(frame absd_user_fields:handle).

define new shared workfile work_abs_mstr like abs_mstr.

/* CUSTOMER SEQ. SCHEDULES INSTALLED? */
{gpfile.i &file_name = """"rcf_ctrl""""}

if can-find (mfc_ctrl where
             mfc_field = "enable_sequence_schedules" and mfc_logical) and
             file_found
then
   using_seq_schedules = yes.

lot-lbl = getTermLabelRtColon("LOT/SERIAL_NUMBERS_SHIPPED", 27) + " " +
          getTermLabelRt("QUANTITY", 6) + " " +
          getTermLabelRt("EXPIRE", 8) + " " +
          getTermLabelRt("REFERENCE", 12).

find abs_mstr where recid(abs_mstr) = global_recid no-lock no-error.

if available abs_mstr and
   (abs_id begins "S" or abs_id begins "C") and
   abs_type = "S"
then do:

   find si_mstr where si_site = abs_shipfrom no-lock.

   assign
      shipfrom = abs_shipfrom
      shp-id   = substring(abs_id,2,50).

   display
      abs_shipfrom           @ shipfrom
      si_desc
      abs_id format "x(1)"   @ type
      substring(abs_id,2,50) @ shp-id
   with frame a.
end.

display type with frame a.

for first soc_ctrl
fields (soc_company)
no-lock: end.

/* DETERMINE IF CONTAINER AND LINE CHARGES IS ENABLED */
{cclc.i}

mainloop:
repeat:

   /* SET DEFAULT COMPANY ADDRESS */
   if comp_addr = "" and available soc_ctrl then
      comp_addr = soc_company.

   update
      type
      shipfrom
      shp-id
      print_lotserials
      l_print_sodet
      comp_addr
   with frame a editing:

      assign
         global_site = shipfrom
         global_loc = substring(string(type),1,1).

      if frame-field = "shipfrom" then do:
         {mfnp05.i abs_mstr abs_id
            "abs_id begins (if input type then 's' else 'c')"
            abs_shipfrom
            shipfrom}
         if recno <> ? then do:
            find si_mstr where si_site = abs_shipfrom no-lock no-error.
            disp_abs_id = substring(abs_id,2,50).
            display
               abs_shipfrom @ shipfrom
               si_desc         when(available si_mstr)
               ""              when(not available si_mstr) @ si_desc
               disp_abs_id @ shp-id
            with frame a.
         end.
      end.
      else if frame-field = "shp-id" then do:
         {mfnp05.i abs_mstr abs_id
            "abs_shipfrom = input shipfrom
             and abs_id begins (if input type then 's' else 'c')"
            abs_id
            " ""s"" + shp-id"}
         if recno <> ? then do:
            find si_mstr where si_site = abs_shipfrom no-lock no-error.
            disp_abs_id = substring(abs_id,2,50).
            display
               abs_shipfrom @ shipfrom
               si_desc       when(available si_mstr)
               ""            when(not available si_mstr) @ si_desc
               disp_abs_id @ shp-id
            with frame a.
         end.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.

   end.

   /* VALIDATE THE COMPANY ADDRESS ONLY IF IT IS NOT BLANK */
   if comp_addr <> "" then do:

      for first ad_mstr
      fields (ad_addr ad_city ad_country ad_format ad_line1
              ad_line2 ad_line3 ad_name ad_ref ad_state ad_zip)
         where ad_addr = comp_addr no-lock:
      end. /* FOR FIRST ad_mstr */

      if not available ad_mstr then do:
         /* INVALID COMPANY ADDRESS */
         {pxmsg.i &MSGNUM=3516 &ERRORLEVEL=3}
         next-prompt comp_addr with frame a.
         undo mainloop, retry mainloop.
      end. /* IF NOT AVAILABLE AD_MSTR */

      for first ls_mstr
      fields (ls_addr ls_type)
         where ls_addr = ad_addr and
               ls_type = "company"
      no-lock: end.

      if not available ls_mstr then do:
         /* INVALID COMPANY ADDRESS */
         {pxmsg.i &MSGNUM=3516 &ERRORLEVEL=3}
         next-prompt comp_addr with frame a.
         undo mainloop, retry mainloop.
      end. /* IF NOT AVAILABLE LS_MSTR */

   end. /* IF comp_addr <> "" */

   clear frame c all no-pause.

   assign ctype = if type then "S" else "C".

   find abs_mstr where abs_shipfrom = shipfrom
                   and abs_id = ctype + shp-id
                   and abs_type = "S"
   no-lock no-error.

   if not available abs_mstr then do:
      {pxmsg.i &MSGNUM=8123 &ERRORLEVEL=3}
      undo, retry.
   end.

   {&RCRP11-P-TAG1}
   if abs_id begins "S" and
      abs_inv_mov <> "" and
      not can-find (first im_mstr where
                          im_inv_mov = abs_inv_mov and
                          im_tr_type = "ISS-SO")
   then do:
      {&RCRP11-P-TAG2}
      /* Not a Sales Order Shipper */
      {pxmsg.i &MSGNUM=5802 &ERRORLEVEL=3}
      undo, retry.
   end.  /* if abs_id */

   assign
      abs_recid   = recid(abs_mstr)
      shipper_id  = substring(abs_id,2)
      ship_date   = abs_shp_date
      absshipto   = abs_shipto
      order-um    = abs_wt_um.

   if available abs_mstr and (abs_id begins "S" or abs_id begins "C")
      and abs_type = "S"
   then
      abs-confirm = substring(abs_status,2,1) .
   else
      abs-confirm = " ".

   find si_mstr where si_site = abs_shipfrom no-lock.

   if substring(abs_status,1,1) = "y" then do:
      {pxmsg.i &MSGNUM=8124 &ERRORLEVEL=2}
   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


   /* GET COMPANY ADDRESS */
   run get-company-address .

   /* GET SOLDTO & SHIPTO ADDRESSES */
   assign
      shipto       = ""
      cust         = ""
      ship         = ""
      l_abs_shipto = "".

   if abs_id begins "c" and abs_shipto = ""
   then
      run p-get-parent-id
         (input abs_recid,
          output l_abs_shipto).

   if l_abs_shipto <> "" then
   for first ad_mstr
   fields(ad_addr ad_city ad_country ad_format ad_line1
          ad_line2 ad_line3 ad_name ad_ref ad_state ad_zip)
      where ad_addr = l_abs_shipto
   no-lock: end.

   else
   if (l_abs_shipto = "" and not(abs_id begins "C")) or
      (abs_shipto <> ""  and (abs_id begins "C"))
   then
      find ad_mstr where ad_addr = abs_shipto no-lock.

   if (l_abs_shipto <> "") or
      (l_abs_shipto = "" and not(abs_id begins "C")) or
      (abs_shipto <> ""  and (abs_id begins "C"))
   then do:
      assign
         shipto_id = ad_addr
         ship = ad_addr

         addr[1] = ad_name
         addr[2] = ad_line1
         addr[3] = ad_line2
         addr[4] = ad_line3
         addr[6] = ad_country.

      {mfcsz.i addr[5] ad_city ad_state ad_zip}.

      {gprun.i ""gpaddr.p"" }
      assign
         shipto[1] = addr[1]
         shipto[2] = addr[2]
         shipto[3] = addr[3]
         shipto[4] = addr[4]
         shipto[5] = addr[5]
         shipto[6] = addr[6].

   end. /* IF L_ABS_SHIPTO <> "" OR .. */

   assign billto = "".

   if l_abs_shipto <> "" then
   for first ad_mstr
   fields(ad_addr ad_city ad_country ad_format ad_line1
          ad_line2 ad_line3 ad_name ad_ref ad_state ad_zip)
      where ad_addr = l_abs_shipto
   no-lock: end.

   else if (l_abs_shipto = "" and not(abs_id begins "C")) or
           (abs_shipto <> ""  and (abs_id begins "C"))
   then
      find ad_mstr where ad_addr = abs_shipto no-lock.

   if (l_abs_shipto <> "") or
      (l_abs_shipto = "" and not(abs_id begins "c")) or
      (abs_shipto <> ""  and (abs_id begins "c"))
   then do:
      assign
         soldto_id = ad_addr
         cust = ad_addr.

      find ls_mstr where ls_addr = ad_addr and ls_type = "customer"
      no-lock no-error.

      if not available ls_mstr and ad_ref > "" then do:

         find ls_mstr where ls_addr = ad_ref and ls_type = "customer"
         no-lock no-error.

         if available ls_mstr then
            assign
               soldto_id = ad_ref
               cust = ad_ref.

         else do:
            addr_id = ad_ref.
            find ad_mstr where ad_addr = addr_id no-lock.
            if ad_ref > "" then do:
               find ls_mstr where ls_addr = ad_ref and ls_type = "customer"
               no-lock no-error.
               if available ls_mstr then
                  assign
                     soldto_id = ad_ref
                     cust = ad_ref.
            end.
         end.

      end.

   end. /* IF L_ABS_SHIPTO <> "" OR .. */

   if l_abs_shipto <> "" then
   for first ad_mstr
   fields(ad_addr ad_city ad_country ad_format ad_line1
          ad_line2 ad_line3 ad_name ad_ref ad_state ad_zip)
      where ad_addr = l_abs_shipto
   no-lock: end.

   else
   if (l_abs_shipto = "" and not(abs_id begins "c")) or
      (abs_shipto <> ""  and (abs_id begins "c"))
   then
      find ad_mstr where ad_addr = soldto_id no-lock.

   if (l_abs_shipto <> "") or
      (l_abs_shipto = "" and not(abs_id begins "c")) or
      (abs_shipto <> ""  and (abs_id begins "c"))
   then do:
      assign
         addr[1] = ad_name
         addr[2] = ad_line1
         addr[3] = ad_line2
         addr[4] = ad_line3
         addr[6] = ad_country.

      {mfcsz.i addr[5] ad_city ad_state ad_zip}.

      {gprun.i ""gpaddr.p"" }

      assign
         billto[1] = addr[1]
         billto[2] = addr[2]
         billto[3] = addr[3]
         billto[4] = addr[4]
         billto[5] = addr[5]
         billto[6] = addr[6].

   end. /* IF L_ABS_SHIPTO <> "" OR .. */

   for each work_abs_mstr exclusive-lock:
      delete work_abs_mstr.
   end.

   /* EXPLODE SHIPPER/CONTAINER TO GET LOWLEVEL ITEM DETAIL */
   {gprun.i ""rcrp11a.p"" "(input recid(abs_mstr))"}

   print_date = today.

   assign
      abs_shipvia    = substring(abs_mstr.abs__qad01,1,20)
      abs_fob        = substring(abs_mstr.abs__qad01,21,20)
      abs_carr_ref   = substring(abs_mstr.abs__qad01,41,20)
      abs_trans_mode = substring(abs_mstr.abs__qad01,61,20)
      abs_veh_ref    = substring(abs_mstr.abs__qad01,81,20).

   /* PRINT HEADING */
   if abs_id begins "S" then
      assign
         rpt_type = getTermLabelRt("BANNER_SHIPPER", 23)
         type_nbr = getTermLabelRtColon("SHIPPER_NUMBER", 17).
   else
      assign
         rpt_type = getTermLabelRt("BANNER_PACKING_LIST", 23)
         type_nbr = getTermLabelRtColon("CONTAINER_ID", 17).

   FORM /*GUI*/  header
      skip (3)
      company[1]                                   at 4
      rpt_type                                     to 79
      company[2]                                   at 4
      sequence_list                                to 79
      company[3]                                   at 4
      type_nbr                                     to 58
      shipper_id
      company[4]                                   at 4
      getTermLabelRtColon("SHIP_DATE", 15) format "x(15)" to 58
      ship_date
      company[5]                                   at 4
      getTermLabelRtColon("PRINT_DATE", 15) format "x(15)" to 58
      print_date
      getTermLabelRtColon("PAGE_OF_REPORT", 16) format "x(16)" to 58
      string(page-number)
      company[6]                                   at 4
      skip (1)
      getTermLabel("SOLD_TO", 26) + ": " + cust format "x(37)" at 8
      getTermLabel("SHIP_TO", 26) + ": " + ship format "x(44)" at 46
      skip (1)
      billto[1]                                    at 8
      shipto[1]                                    at 46
      billto[2]                                    at 8
      shipto[2]                                    at 46
      billto[3]                                    at 8
      shipto[3]                                    at 46
      billto[4]                                    at 8
      shipto[4]                                    at 46
      billto[5]                                    at 8
      shipto[5]                                    at 46
      billto[6]                                    at 8
      shipto[6]                                    at 46
      skip (2)
      skip(3)
      getTermLabelRtColon("SHIP_VIA", 12) format "x(12)"  to 12
      abs_shipvia
      getTermLabelRtColon("MODE_OF_TRANSPORT", 24) format "x(24)" to 58
      abs_trans_mode
      getTermLabelRtColon("FOB_POINT", 12) format "x(12)"  to 12
      abs_fob
      getTermLabelRtColon("CARRIER_SHIPMENT_REFERENCE", 24)
      format "x(24)"  to 58
      abs_carr_ref
      getTermLabelRtColon("VEHICLE_ID", 24) format "x(24)"  to 58
      abs_veh_ref
      skip(3)
   with STREAM-IO /*GUI*/  frame heading page-top width 90 no-box
   no-attr-space no-labels.

   view frame heading.

   /* PRINT COMMENTS IF ANY */
   if abs_cmtindx > 0 then do:
      {gpcmtprt.i &type=SH &id=abs_cmtindx &pos=3}
      put skip(1).
   end.

   /* PRINT CONTAINER/LINE CHARGES HEADER USER FIELDS */
   if using_container_charges or using_line_charges then do:

      for each absd_det no-lock where
               absd_abs_id = abs_id  and
               absd_shipfrom = abs_shipfrom
      break by absd_abs_id:

         display
            absd_fld_seq @ v_absd_fld_seq
            absd_fld_name @ v_absd_fld_name
            absd_fld_value @ v_absd_fld_value
         with frame absd_user_fields STREAM-IO /*GUI*/ .

         down 1 with frame absd_user_fields.

         if last-of(absd_abs_id) then
            down 2 with frame absd_user_fields.

      end. /* FOR EACH absd_det */

   end. /* IF using_container or using_line_charges */

   /* Warn if there is any sales orders on the shipper that has
    * it's action status non-blank. We check before starting to print
    * anything */
   non_blank_so_stat = no.

   for each work_abs_mstr no-lock
         break by abs_shipfrom by abs_dataset by abs_order:
      if first-of (abs_order) then do:
         find so_mstr where so_nbr = abs_order no-lock no-error.
         if available so_mstr and so_stat <> "" then
            non_blank_so_stat = yes.
      end. /* if first-of  abs_order */
   end. /* for each work_abs_mstr */

   /* PRINT DETAIL */
   for each work_abs_mstr no-lock
   break by abs_item by abs_order by abs_line:

      accumulate abs_qty(sub-total by abs_line).
      accumulate abs_ship_qty(sub-total by abs_line).

      if print_lotserials then do:
         create abs_work.
         assign
            abs_work.abs-lotser = work_abs_mstr.abs_lotser
            abs_work.abs-ref    = work_abs_mstr.abs_ref
            abs_work.abs-qty    = work_abs_mstr.abs_qty
            abs_work.abs-loc    = work_abs_mstr.abs_loc
            abs_work.abs-site   = work_abs_mstr.abs_site.
      end.

      if last-of(abs_line) then do:

         disp_item = abs_item.
         cum_qty = (accum sub-total by abs_line abs_qty) -
                   (accum sub-total by abs_line abs_ship_qty).

         find first so_mstr where so_nbr = abs_order
         no-lock no-error.

         /* USING IDH_CONTR_ID TO FACILITATE PO NUMBER PRINTING FOR  */
         /* DISCRETE AS WELL AS SCHEDULED ORDERS,                    */
         /* IF SALES ORDER IS NOT AVAILABLE                          */
         find sod_det where sod_nbr = abs_order
                        and sod_line = integer(abs_line)
         no-lock no-error.

         if available sod_det then do:

            disp_item = sod_part.

            find cp_mstr where cp_cust = absshipto
                           and cp_cust_part = sod_custpart
            no-lock no-error.

            if not available cp_mstr then
               find cp_mstr where cp_cust = cust and
                                  cp_cust_part = sod_custpart
               no-lock no-error.

            if not available cp_mstr then
               for first cp_mstr
               fields(cp_cust cp_cust_eco cp_cust_part cp_cust_partd)
                  where cp_cust      = "" and
                        cp_cust_part = sod_custpart
               no-lock: end.

            find pt_mstr where pt_part = sod_part no-lock no-error.

            disp_item = sod_part.
            if sod_custpart > "" then
               disp_item = sod_custpart.
            if available cp_mstr and cp_cust_partd > "" then
               disp_item = cp_cust_partd.

            /* CUM_QTY NEED TO DISPLAYED IN SHIP UM */
            cum_qty = cum_qty + (sod_cum_qty[1] * sod_um_conv) /
                      decimal(abs__qad03).

            /*IF SHIPPER IS CONFIRMED THEN GET THE SOD_CUM_QTY */
            if abs-confirm  = "y" then
               cum_qty = (sod_cum_qty[1] * sod_um_conv) / decimal(abs__qad03).

            if sod_sched then
               shipper-po = sod_contr_id.
            else if available so_mstr then
               shipper-po = so_ship_po.

         end. /* IF AVAILABLE SOD_DET */

         else do:

            for first idh_hist
            fields(idh_contr_id idh_line idh_nbr idh_part idh_sched)
               where idh_nbr = abs_order and
                     idh_line = integer(abs_line) and
                     idh_part = abs_item
            no-lock: end.

            if available idh_hist then do:
               if idh_sched then
                  shipper-po = idh_contr_id.
               else do:
                  for first ih_hist
                  fields(ih_nbr ih_ship_po)
                     where ih_nbr = idh_nbr
                  no-lock:
                     shipper-po = ih_ship_po.
                  end.
               end. /* ELSE DO */
            end. /* IF AVAILABLE IDH_HIST */
            else
               shipper-po = "".

         end. /* NOT AVAILABLE SOD_DET */

         display
            disp_item
            shipper-po
            accum sub-total   by work_abs_mstr.abs_line
            work_abs_mstr.abs_qty @ ship_qty
            cum_qty           when (available sod_det)
            abs__qad02 @ pt_um
         with frame c STREAM-IO /*GUI*/ .

         down with frame c.

         if available cp_mstr and available pt_mstr then do:

            if disp_item          = cp_cust_partd
               and cp_cust_partd <> cp_cust_part
               or  cp_cust_part  =  pt_part
               and cp_cust_partd <> ""
            then do:
               put
                  {gplblfmt.i &FUNC=getTermLabel(""CUSTOMER_ITEM"",30)
                              &CONCAT="':'"} at 1 sod_custpart.
               /*IF THE CUSTOMER ITEM IS DIFFERENT THAN THE */
               /*CUSTOMER REF THEN DISPLAY THE CUST_REF     */
               if  ((available sod_det)
                  and (sod_custref <> sod_custpart)
                  and (sod_custref <> ""))
               then
                  put
                     {gplblfmt.i &FUNC=getTermLabel(""CUSTOMER_REFERENCE"",30)
                                 &CONCAT="':'"} at 1 sod_custref.
          end.  /* IF DISP_ITEM = CP_CUST_PARTD..... */

            if cp_cust_partd     <> pt_part
               and cp_cust_partd <> ""
               or  cp_cust_partd = cp_cust_part
            then
               put
                  {gplblfmt.i &FUNC=getTermLabel(""ITEM_NUMBER"",30)
                              &CONCAT="'  :'"} at 1 pt_part.

            if disp_item         = sod_custpart
               and cp_cust_partd = ""
               and cp_cust_part  <> pt_part
            then
               put
                  {gplblfmt.i &FUNC=getTermLabel(""ITEM_NUMBER"",30)
                              &CONCAT="'  :'"} at 1 pt_part.
         end. /* IF AVAILABLE CP_MSTR AND AVAILABLE PT_MSTR */
         else
         if  ((available sod_det) and (sod_custref <> "")) then
            put
               {gplblfmt.i &FUNC=getTermLabel(""CUSTOMER_REFERENCE"",30)
                           &CONCAT="':'"} at 1 sod_custref.

         if  ((available sod_det) and (sod_modelyr <> "")) then
           put
              {gplblfmt.i &FUNC=getTermLabel(""MODEL_YEAR"",30)
                          &CONCAT="':'"} at 1 sod_modelyr.

         if available cp_mstr and cp_cust_eco <> "" then do:
            display
               cp_cust_eco @ disp_item
            with frame c STREAM-IO /*GUI*/ .
            down with frame c.
         end. /* IF AVAILABLE CP_MSTR AND CP_CUST_ECO <> ""  */

         display
            " " @ disp_item
         with frame c STREAM-IO /*GUI*/ .
         down with frame c.

         if l_print_sodet then do:

            msgdesc = "".

            if abs-confirm <> "y" and not available sod_det
            then do:
               /* DOES NOT EXIST. CANNOT CONFIRM. */
               {pxmsg.i &MSGNUM=1868 &ERRORLEVEL=1 &MSGBUFFER=msgdesc}
               msgdesc = getTermLabelRtColon("SALES_ORDER", 12) + " " +
                         abs_order + " " +
                         getTermLabelRtColon("LINE", 5) + " " +
                         string(abs_line,"x(4)") + msgdesc.
            end.
            else do:
               if available sod_det then
                  msgdesc = getTermLabelRtColon("SALES_ORDER", 12) + " " +
                            sod_nbr + " " +
                            getTermLabelRtColon("LINE", 5) + " " +
                            string(sod_line).
               else
                  msgdesc = getTermLabelRtColon("SALES_ORDER", 12) + " " +
                            abs_order + " " +
                            getTermLabelRtColon("LINE", 5) + " " +
                            string(abs_line,"x(4)").
            end.

            if page-size - line-counter < 2 then page.
            put msgdesc at 3 skip(1).

         end. /* IF l_print_sodet */

         if print_lotserials then do:

            put lot-lbl at 3 skip.

            for each abs_work no-lock:

               find ld_det where
                      ld_part = work_abs_mstr.abs_item
                  and ld_site = abs_work.abs-site
                  and ld_loc  = abs_work.abs-loc
                  and ld_lot  = abs_work.abs-lotser
                  and ld_ref  = abs_work.abs-ref
               no-lock no-error.

               if available ld_det then
                  ld-expire = ld_expire.
               else
                  ld-expire = ?.

               put
                  abs_work.abs-lotser at 5
                  abs_work.abs-qty    at 27 format "->>>>>>9.9<<<<<<"
                  ld-expire           at 40
                  abs_work.abs-ref    at 50
                  skip.

            end.

            for each abs_work exclusive-lock:
               delete abs_work.
            end.

         end.

      end.

      /* PRINT CONTAINER/LINE CHARGES LINE LEVEL USER FIELDS */
      if using_container_charges or using_line_charges then do:

         for each absd_det no-lock where
               absd_abs_id = work_abs_mstr.abs_id  and
               absd_shipfrom = work_abs_mstr.abs_shipfrom
         break by absd_abs_id:

            display
               absd_fld_seq   @ v_absd_fld_seq
               absd_fld_name  @ v_absd_fld_name
               absd_fld_value @ v_absd_fld_value
            with frame absd_user_fields STREAM-IO /*GUI*/ .

            down 1 with frame absd_user_fields.

            if last-of(absd_abs_id) then
               down 2 with frame absd_user_fields.

         end. /* FOR EACH absd_det */

      end. /* IF using_container or using_line_charges */

      
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/


   end.

   put skip(3).

   /* PRINT SEQUENCES AND A SEPARATE SEQUENCE PACKING LIST */
   if using_seq_schedules then do:

      abs_recid_seq = recid(abs_mstr).

      for first rcf_ctrl no-lock: end.

      for first rcc_mstr where rcc_addr = so_ship
      no-lock: end.

      /* CHECK TO MAKE SURE WE'RE AT THE */
      /* PRE-SHIPPER OR SHIPPER LEVEL.   */
      if abs_id begins "P" or abs_id begins "S"
      then do:

         /* DETERMINE IF SEQ. RANGE SHOULD BE PRINTED */
         if available rcc_mstr and rcc_shipper_print
         or (not available rcc_mstr and available rcf_ctrl and
            rcf_shipper_print)
         then do:

            /*GET SEQUENCE SCHEDULE DATA*/
            {gprunmo.i
               &program = ""rcsqprt.p""
               &module = "ASQ"
               &param = """(input abs_recid_seq,
                            input '')"""}

            /* PRINTING CUSTOMER SEQUENCE RANGE */
            for each t_abss_det
            break by t_abss_ship_id
                  by t_abss_from_cust_job:

               {&PAGEBREAK}

               if first-of(t_abss_ship_id) then
                  put
                     {gplblfmt.i &FUNC=getTermLabel(""SEQUENCE_RANGES"",20)}
                     at 25.

               if first-of(t_abss_from_cust_job) and
                  t_abss_from_cust_job <> ""
               then
                  put
                     {gplblfmt.i &FUNC=getTermLabel(""CUSTOMER_JOB"",20)
                                 &CONCAT="': '"} at 5
                     t_abss_from_cust_job.

               display
                  t_abss_from_cust_seq
                  t_abss_to_cust_seq
               with frame sequence2 STREAM-IO /*GUI*/ .

               down with frame sequence2.

            end. /* END OF FOR EACH abss_det */

            /* DELETING THE WORKFILE */
            for each t_abss_det exclusive-lock:
               delete t_abss_det.
            end.

         end.  /* available rcc_mstr or rcf_ctrl */

      end.  /* if abs_id begins "p" ... */

   end. /* if enable sequenced schedules */

   /* PRINT WEIGHT SUMMARY */

   assign
      par_shipfrom    = abs_shipfrom
      par_id          = abs_id
      l_net_wt1       = 0
      l_tare_wt1      = 0
      l_gross_wt1     = 0
      l_net_wt2       = 0
      l_tare_wt2      = 0
      l_gross_wt2     = 0
      l_first_part_um = "".

   /* CREATED INTERNAL PROCEDURE P-GET-PARENT-WT-UM TO GET THE */
   /* PARENT WEIGHT UM                                         */
   run p-get-parent-wt-um
      (input recid(abs_mstr),
       output l_parent_tare_wt,
       output l_first_part_um).

   assign
      l_tare_wt2 =  l_tare_wt2  + l_parent_tare_wt
      l_gross_wt2 = l_gross_wt2 + l_parent_tare_wt .


   for each abs_mstr no-lock
      where abs_shipfrom = par_shipfrom and abs_par_id = par_id,
      each pt_mstr no-lock where pt_part = abs_item
   break by pt_part with frame frm_part:

      setFrameLabels(frame frm_part:handle).

      /* TO CALCULATE CORRECT TOTALS FOR NET WEIGHT, TARE WEIGHT AND */
      /* GROSS WEIGHT WHEN A SHIPPER IS CREATED FOR A SALES ORDER    */
      /* HAVING MULTIPLE LINE ITEMS EACH WITH DIFFERENT WEIGHT UM.   */
      l_abs_twt = abs_gwt - abs_nwt.

      if first-of(pt_part)
      then
         l_part_um = abs_wt_um.

      if l_part_um <> abs_wt_um
      then do:

         {gprun.i ""gpumcnv.p""
            "(l_part_um,
              abs_wt_um,
              """",
              output l_conv)" }

         if l_conv = ? then
            l_conv = 1.

         assign
            l_qty       = l_qty       + abs_qty
            l_net_wt1   = l_net_wt1   + abs_nwt / l_conv
            l_gross_wt1 = l_gross_wt1 + abs_gwt / l_conv
            l_tare_wt1  = l_tare_wt1  + l_abs_twt / l_conv.

      end. /* IF l_part_um <> abs_wt_um THEN */
      else
         assign
            l_qty       = l_qty       + abs_qty
            l_net_wt1   = l_net_wt1   + abs_nwt
            l_tare_wt1  = l_tare_wt1  + l_abs_twt
            l_gross_wt1 = l_gross_wt1 + abs_gwt.

      if l_first_part_um <> abs_wt_um
      then do:

         {gprun.i ""gpumcnv.p""
            "(l_first_part_um,
              abs_wt_um,
              """",
              output l_conv)" }

         if l_conv = ? then
            l_conv = 1.

         assign
            l_net_wt2   = l_net_wt2   + abs_nwt / l_conv
            l_gross_wt2 = l_gross_wt2 + abs_gwt / l_conv
            l_tare_wt2  = l_tare_wt2  + l_abs_twt / l_conv.

      end. /* IF l_first_part_um <> abs_wt_um THEN */
      else
         assign
            l_net_wt2   = l_net_wt2   + abs_nwt
            l_gross_wt2 = l_gross_wt2 + abs_gwt
            l_tare_wt2  = l_tare_wt2  + l_abs_twt.

      if last-of(pt_part) then do:
         display
            pt_desc1
            l_qty       @ abs_qty   column-label "Qty"
                                    format "->>>>>>9.9"
            l_net_wt1   @ abs_nwt   column-label "Net!Weight"
                                    format "->>>>>>9.9"
            l_tare_wt1  @ l_abs_twt column-label "Tare!Weight"
                                    format "->>>>>>9.9"
            l_gross_wt1 @ abs_gwt   column-label "Gross!Weight"
                                    format "->>>>>>9.9"
            l_part_um   @ abs_wt_um
         with width 80
         title color normal (getFrameTitle("SHIPMENT_WEIGHT_SUMMARY",33)) STREAM-IO /*GUI*/ .

         assign
            l_qty       = 0
            l_net_wt1   = 0
            l_tare_wt1  = 0
            l_gross_wt1 = 0.

      end. /* IF LAST-OF(PT_PART) */

      if last(pt_part) then do:

         if l_parent_tare_wt > 0
         then do:

            down.

            display
               getTermLabel("PARENT_LEVEL_TARE_WEIGHT",20) @ pt_desc1
               l_parent_tare_wt @ l_abs_twt  format "->>>>>>9.9<<"
               l_parent_tare_wt @ abs_gwt    format "->>>>>>9.9<<"
               l_first_part_um  @ abs_wt_um  WITH STREAM-IO /*GUI*/ .

         end. /* IF l_parent_tare_wt > 0 */

         down 1.

         underline abs_nwt l_abs_twt abs_gwt.

         down 1.

         display
            l_net_wt2       @ abs_nwt   column-label "Net!Weight"
                                        format "->>>>>>9.9<<"
            l_tare_wt2      @ l_abs_twt column-label "Tare!Weight"
                                        format "->>>>>>9.9<<"
            l_gross_wt2     @ abs_gwt   column-label "Gross!Weight"
                                        format "->>>>>>9.9<<"
            l_first_part_um @ abs_wt_um
         with width 80
         title color normal (getFrameTitle("SHIPMENT_WEIGHT_SUMMARY",33)) STREAM-IO /*GUI*/ .

      end. /* IF LAST(PT_PART) */

      /* PRINT SEQUENCES AND A SEPARATE SEQUENCE PACKING LIST */
      if using_seq_schedules then do:
         sequence_list = getTermLabel("BANNER_SEQUENCE_PACKING_LIST", 36).
         {gprunmo.i
            &program = ""sosob2.p""
            &module = "ASQ"
            &param = """(input abs_recid_seq,
                         input-output v_start_page)"""}
         sequence_list = "".
      end.  /* if using_seq_schedules */

      
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/


   end.

   hide frame heading.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


   if non_blank_so_stat  then do:
      {pxmsg.i &MSGNUM=623 &ERRORLEVEL=2} /* SALES ORDER STATUS NOT BLANK */
   end.

   do transaction:
      /* MARK PRINTED */
      find abs_mstr where recid(abs_mstr) = abs_recid exclusive-lock.

      substring(abs_status,1,1) = "y".

      assign
         global_recid = recid(abs_mstr).

      release abs_mstr.
   end.

end.

PROCEDURE get-company-address:

   assign company = "".

   for first ad_mstr
   fields(ad_addr  ad_city  ad_country ad_format
          ad_line1 ad_line2 ad_line3   ad_name
          ad_ref   ad_state ad_zip )
      where ad_addr = comp_addr
   no-lock: end.

   if available ad_mstr then do:
      assign
         addr[1] = ad_name
         addr[2] = ad_line1
         addr[3] = ad_line2
         addr[4] = ad_line3
         addr[6] = ad_country.

      {mfcsz.i addr[5] ad_city ad_state ad_zip}.
      {gprun.i ""gpaddr.p"" }

      assign
         company[1] = addr[1]
         company[2] = addr[2]
         company[3] = addr[3]
         company[4] = addr[4]
         company[5] = addr[5]
         company[6] = addr[6].
   end. /* IF AVAILABLE AD_MSTR */

END PROCEDURE. /* get-company-address */

PROCEDURE p-get-parent-id:

   define input  parameter i_recid      as   recid      no-undo.
   define output parameter l_abs_shipto like abs_shipto no-undo.

   define variable l_par_recid as recid no-undo.
   define buffer b_abs_mstr for abs_mstr.

   /* FIND TOP-LEVEL PARENT SHIPPER OR PRESHIPPER */
   {gprun.i ""gpabspar.p""
      "(i_recid, 'PS', false, output l_par_recid)" }

   for first b_abs_mstr
   fields(abs_cmtindx abs_gwt abs_id abs_inv_mov abs_item
          abs_loc abs_nwt abs_par_id abs_qty abs_shipfrom
          abs_shipto abs_shp_date abs_status abs_type
          abs_wt_um abs__qad01)
      where recid(b_abs_mstr) = l_par_recid
   no-lock: end.

   if available b_abs_mstr             and
      (b_abs_mstr.abs_id begins "s"    or
       b_abs_mstr.abs_id begins "p")   and
       b_abs_mstr.abs_shipto <> ""
   then
      l_abs_shipto = abs_shipto.
   else
      l_abs_shipto = "".

END PROCEDURE.

PROCEDURE p-get-parent-wt-um:

   define input  parameter l_recid          as   recid      no-undo.
   define output parameter l_parent_tare_wt like abs_nwt    no-undo.
   define output parameter l_first_part_um  like abs_wt_um  no-undo.

   define         variable l_par_recid     as recid        no-undo.
   define buffer b_abs_mstr for abs_mstr.

   /* FIND TOP-LEVEL PARENT SHIPPER OR PRESHIPPER */
   {gprun.i ""gpabspar.p""
      "(l_recid, 'PS', false, output l_par_recid)" }

   for first b_abs_mstr
   fields(abs_cmtindx abs_gwt abs_id abs_inv_mov abs_item
          abs_loc abs_nwt abs_par_id abs_qty abs_shipfrom
          abs_shipto abs_shp_date abs_status abs_type
          abs_wt_um abs__qad01)
      where recid(b_abs_mstr) = l_par_recid
   no-lock: end.

   if available b_abs_mstr             and
      (b_abs_mstr.abs_id begins "s"    or
       b_abs_mstr.abs_id begins "p")
   then
      l_first_part_um = abs_wt_um.

   {absupack.i  "b_abs_mstr" 26 22 "l_parent_tare_wt" }

END PROCEDURE.
